package by.amakarevich.webapp.page.booking.user;

import java.util.Date;

import javax.inject.Inject;

import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;

import by.amakarevich.datamodel.Booking;
import by.amakarevich.services.BookingService;
import by.amakarevich.webapp.page.booking.info.BookingInfoPage;
import by.amakarevich.webapp.page.home.HomePage;

public class UserBookingPanel extends Panel {
	
	@Inject
	private BookingService bookingService;
	private Booking booking;


	public UserBookingPanel(String id, Long bookingId) {
		super(id);
		booking = bookingService.get(bookingId);
	}

	public UserBookingPanel(String id, Booking booking) {
		super(id);
		this.booking = booking;
	}

	@Override
	protected void onInitialize() {
		super.onInitialize();
		WebMarkupContainer liContainer = new WebMarkupContainer("wrapper-li");
		add(liContainer);

		WebMarkupContainer hContaienr = new WebMarkupContainer("wrapper-h");
		liContainer.add(hContaienr);

		hContaienr.add(new Label("id", new Model<Long>(booking.getId())));
		liContainer.add(new Label("received", new Model<Date>(booking.getReceived())));
		liContainer.add(new CheckBox("status", new Model<Boolean>(booking.getStatus())).setEnabled(false));
		liContainer.add(new CheckBox("payStatus", new Model<Boolean>(booking.getPayStatus())).setEnabled(false));
		liContainer.add(new CheckBox("canceled", new Model<Boolean>(booking.getCanceled())).setEnabled(false));
		liContainer.add(new Label("totalPrice", new Model<Long>(booking.getTotalPrice())));
		
		liContainer.add(new Link("booking-info-page-link") {
			@Override
			public void onClick() {
				setResponsePage(new BookingInfoPage(booking));
			}
		});
	}

	

}
